package com.newidea.jiangong.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Schema(title = "设备状态")
@Data
public class FacilityState {

    @Schema(title = "设备名称")
    private String name;

    @Schema(title = "设备状态")
    private String state;

    /**
     * 创建设备状态
     *
     * @param name   设备名称
     * @param value1 设备第一个值
     * @param value2 设备第一个值
     * @return 设备状态
     */
    public static FacilityState createFacilityState(String name, String value1, String value2) {
        // 默认就是未启动，也就是 value1和value2都未启动
        String state = "未启动";
        if (name.startsWith("锅炉")) {
            if ("1".equals(value1)) {
                state = "燃烧";
            } else if ("1".equals(value2)) {
                state = "故障";
            }
        } else if (name.startsWith("循环泵") || name.startsWith("补水泵")) {
            if ("1".equals(value1)) {
                state = "运行";
            } else if ("1".equals(value2)) {
                state = "故障";
            }
        } else if (name.startsWith("蝶阀")) {
            if ("1".equals(value1)) {
                state = "关闭";
            } else if ("1".equals(value2)) {
                state = "打开";
            }
        }

        FacilityState facilityState = new FacilityState();
        facilityState.setName(name);
        facilityState.setState(state);
        return facilityState;
    }
}
